#pragma once

#include "rpcsal.h"
#include "Vss.h"
#include "VsWriter.h"
#include "vsbackup.h"

#define		VSS_PIPE_INPUT_SIZE	256
#define		VSS_PIPE_OUTPUT_SIZE	256
#define		VSS_PIPE_TIMEOUT		3*1000
#define		VSS_PIPE_NAME			L"\\\\.\\pipe\\nerbiu\\vsspipe"
#define		VSS_PIPE_CONTENT		L"MySoftwareProvider"

class CVssOpRequester
{
public:
	CVssOpRequester(void);
	~CVssOpRequester(void);

public:
	void Initialize();

	// Create the shadow copy set
	void CreateSnapshotSet();

	// Waits for the completion of the asynchronous operation
    HRESULT WaitAndCheckForAsyncOperation(IVssAsync* pAsync);

	// Needed to issue VSS calls 
    CComPtr<IVssBackupComponents>   m_pVssObject;

	// Latest shadow copy set ID
    VSS_ID m_latestSnapshotSetID;

private:
    HRESULT InitSoftwareProvider();
    void	UninitSoftwareProvider();

private:
    DWORD   m_dwFlags;			   // Backup Flags. Please see VSS_FLAG_xxx in abstractvss.h
    HANDLE  m_hPipe;			   // The handle of named pipe.
};
